import request from '@/utils/request'
const VUE_APP_PAY_API = process.env.VUE_APP_PAY_API
/**
 * 创建支付订单
 * http://192.168.88.247:4999/web/#/105/698
 * @param {*} data
 * @returns
 */
export function createOrder (data) {
  return request({
    url: '/api/v1/order/create',
    method: 'post',
    data
  })
}
/**
 * 获取兑换码关联的权益包
 * http://192.168.88.247:4999/web/#/105/1334
 * @param {*} params
 * @returns
 */
export function exchangeCodeResource (params) {
  return request({
    url: '/api/v2/exchange_code/rel_resource',
    method: 'get',
    params
  })
}
/**
 * 用户使用兑换码兑换
 * http://192.168.88.247:4999/web/#/105/1333
 * @param {*} data
 * @returns
 */
export function actExchangeCode (data) {
  return request({
    url: '/api/v1/exchange_code/exchange',
    method: 'post',
    data
  })
}
/**
 * 获取用户订单列表
 * http://192.168.88.247:4999/web/#/105/1342
 * @param {*} params
 * @returns
 */
export function orderListApi (params) {
  return request({
    url: '/api/v1/order/user_list',
    method: 'get',
    params
  })
}
/**
 * 用户兑换列表
 * http://192.168.88.247:4999/web/#/105/1335
 * @param {*} params
 * @returns
 */
export function exchangeListApi (params) {
  return request({
    url: '/api/v1/exchange_code/exchange_list',
    method: 'get',
    params
  })
}
/**
 * 申请开票
 * http://192.168.88.247:4999/web/#/340/3104
 * @returns
 */
export function applyInovice (data) {
  return request({
    url: '/api/v1/invoice/apply_inovice',
    method: 'post',
    data
  })
}
/**
 * 开票列表
 * http://192.168.88.247:4999/web/#/340/3105
 * @returns
 */
export function inoviceList (params) {
  return request({
    url: '/api/v1/invoice/list',
    method: 'get',
    params
  })
}
/**
 * paypal创建订单
 * http://192.168.88.247:4999/web/#/52/1338
 * @returns
 */
export function pay (data) {
  return request({
    url: VUE_APP_PAY_API + '/api/v1/pay',
    method: 'post',
    data
  })
}
/**
 * 轮询订单支付状态
 * http://192.168.88.247:4999/web/#/52/308
 * @returns
 */
export function checkOrder (params) {
  return request({
    noMsg: true,
    url: VUE_APP_PAY_API + '/api/v1/check_order',
    method: 'get',
    params
  })
}

/**
 * 能量明细
 * http://192.168.88.247:4999/web/#/283?page_id=2492
 * @param {*} params
 * @returns
 */
export function energyOrderListApi (params) {
  return request({
    url: '/charge/api/v1/user/bills',
    method: 'get',
    params
  })
}
